<%--
XPTracker - Alternative Agile Tracking Tool
Copyright (C) 2006-2009  Stephen Starkey

This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA
--%>
<%@ include file="/taglibs.jsp" %>
<c:set var="title" value="Administration" scope="request"/>
<s:layout-render name="/layout/normal.jsp">
  <s:layout-component name="body">
    <div class="admin-tool" style="float:right;clear:both">
      <h3>Story Points</h3>
      <s:form beanclass="org.xptracker.web.AdminActionBean">
        <table class="form">
          <tr>
            <td class="form-label">Petit:</td>
            <td><s:text name="points['petit']" size="3"/></td>
            <td class="form-label">Small:</td>
            <td><s:text name="points['small']" size="3"/></td>
            <td class="form-label">Medium:</td>
            <td><s:text name="points['medium']" size="3"/></td>
          </tr>
          <tr>
            <td class="form-label">Large:</td>
            <td><s:text name="points['large']" size="3"/></td>
            <td class="form-label">XL:</td>
            <td><s:text name="points['xl']" size="3"/></td>
          </tr>
          <tr>
            <td></td><td><s:submit name="SetStoryPoints" value="Save"/></td>
          </tr>
        </table>
      </s:form>
    </div>

    <div class="admin-tool" style="float:right;clear:both">
      <script type="text/javascript">
        function getFormatName() {
          var format = prompt('Name of New Link Format');
          if (format) {
            $('formatName').value = format;
            return true;
          }
          return false;
        }
      </script>
      <h3>External Link Formats</h3>
      <s:form beanclass="org.xptracker.web.AdminActionBean">
        <table class="form">
        <c:forEach items="${actionBean.linkFormats}" var="formatEntry">
          <tr>
            <td class="form-label">${formatEntry.key}</td>
            <td><s:text name="linkFormats['${formatEntry.key}']" size="60"/></td>
            <td>[
              <s:link beanclass="org.xptracker.web.AdminActionBean" event="DeleteLinkFormat" onclick="return confirm('Are you sure?');">
                Delete
                <s:param name="formatName">${formatEntry.key}</s:param>
              </s:link>
              ]</td>
          </tr>
        </c:forEach>
        <tr>
          <td></td><td><s:submit name="AddLinkFormat" value="Add" onclick="return getFormatName();"/>
          <s:submit name="SaveLinkFormats" value="Save"/></td>
        </tr>
        </table>
        <input type="hidden" id="formatName" name="formatName"/>
      </s:form>
      Format should be a url with {0} in place of the ID of the item you're linking to:
         <em>http://officeServices/app?id={0}</em> with the name <em>app</em> would be invoked with: <em>app:42</em>
      and render: <a href="http://officeServices/app?id=42">app: 42</a>
    </div>

    <div class="admin-tool">
      <h3>Scheduled Tasks
      [
      <s:link beanclass="org.xptracker.web.AdminActionBean">
        Add
        <s:param name="NewTask" value="1"/>
      </s:link>
      ]</h3>
      <dt:table name="actionBean.scheduledTasks" id="task" class="data">
        <dt:column title="Name">
          <s:link beanclass="org.xptracker.web.AdminActionBean">
            ${task.name}
            <s:param name="LoadTask" value="1"/>
            <s:param name="taskId" value="${task.id}"/>
          </s:link>
        </dt:column>
        <dt:column title="Schedule" property="cronSchedule"/>
        <dt:column title="">
          [
          <s:link beanclass="org.xptracker.web.AdminActionBean">
            ${task.disabled ? 'Enable' : 'Disable'}
            <s:param name="${task.disabled ? 'Enable' : 'Disable'}Task" value="1"/>
            <s:param name="taskId" value="${task.id}"/>
          </s:link>
          ]
          <c:if test="${!task.system}">
          [
          <s:link beanclass="org.xptracker.web.AdminActionBean" onclick="return confirm('Are you sure?')">
            Delete
            <s:param name="DeleteTask" value="1"/>
            <s:param name="taskId" value="${task.id}"/>
          </s:link>
          ]</c:if>
        </dt:column>
      </dt:table>
    </div>


    <div class="admin-tool">
      <h3>Import/Export</h3>
      <s:form beanclass="org.xptracker.web.AdminActionBean" enctype="multipart/form-data">
        <s:file name="fileBean"/>
        <div>
          <s:radio value="users" name="importType"/>
          Import Users <br/>
          <s:radio value="stories" name="importType"/>
          Import Stories <br/>
          <s:radio value="customers" name="importType"/>
          Import Customers<br/>
          <s:radio value="xplanner" name="importType"/>
          Import From XPlanner (Iteration XML File)<br/>
          <s:radio value="bugzilla" name="importType"/>
          Import From Bugzilla (XML File)
        </div>
        <s:submit name="Import" value="Import"/>
      </s:form>

      <div style="margin-left:10px; padding:5px; background-color:#eeeeee;">
        <br/>
        Try the export button below for an example of the format
      </div>
      <br/>
      <s:link beanclass="org.xptracker.web.AdminActionBean" event="Export">
        <s:param name="importType" value="users"/>
        Export Users
      </s:link>
      <br/>
      <s:link beanclass="org.xptracker.web.AdminActionBean" event="Export">
        <s:param name="importType" value="stories"/>
        Export Stories
      </s:link>
      <br/>
      <s:link beanclass="org.xptracker.web.AdminActionBean" event="Export">
        <s:param name="importType" value="customers"/>
        Export Customers
      </s:link>
    </div>
  </s:layout-component>
</s:layout-render>
